export default {
	namespaced : true,
	state : {
		/* 
			浮窗偏移设置，默认xy最终位置，
			lt为以左上偏移，可以设置rb为true变成右下偏移，暂时没有右下
			show控制显示隐藏浮窗
		 */
		pops: {
			stand:{
				x: 0,
				y: 0,
				l: 0,
				t: 10,
				show: false
			},
			gameCenter:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			live:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			cartoon:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			download:{
				x: 0,
				y: 0,
				l: -97,
				t: 6.5,
				show: false
			},
			
			headerSearch:{
				l: 0,
				t: 1,
				show: false
			},
			channelSearch:{
				l: 0,
				t: 1,
				show: false
			},
			
			unLogin:{
				x: 0,
				y: 0,
				l: -140,
				t: 10,
				show: false
			},
			reference:{
				x: 0,
				y: 0,
				l: -172,
				t: 10,
				show: false
			},
			
			myself:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			member:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			news:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			dynamic:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			collect:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			},
			history:{
				x: 0,
				y: 0,
				l: -50,
				t: 10,
				show: false
			}
		},
		// 动漫热门数据以及mock动漫列表数据
		cartoonHot: [],
		cartoonList: [],
		games: {
			banner: {},
			brief: [],
			more: []
		},
		stand: [],// 主站
		live: [],// 直播
	},
	mutations:{
		// 根据name设置该浮窗的显示隐藏
		setPopsShow(state, payload){
			state.pops[payload.name].show = payload.show;
		},
		// 根据name和target，获取元素正下方的位置，并设置好最终x，y
		getComputedPosi(state, obj){
			let target = obj.target,
					name = obj.name,
					rect = target.getBoundingClientRect(),
					r = state.pops[name].r,
					x = parseInt(rect.x),
					y = parseInt(rect.y + rect.height);
			
			state.pops[name].x = x + state.pops[name].l;
			state.pops[name].y = y + state.pops[name].t;
		},
		getCartoonList(state, payload){
			state.cartoonList = payload;
		},
		getCartoonHot(state, payload){
			state.cartoonHot = payload;
		},
		getGames(state, payload){
			state.games = payload;
		},
		getStand(state, payload){
			state.stand = payload.region_count;
		},
		getLive(state, payload){
			state.live = payload;
		}
	}
}